﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using WpfLibrary.Animate;

namespace MyMusicPlay._4._0
{
    public partial class MainWindow : Window
    {
        private Border curDp = null;
        public void PlayBoard_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            var cur = sender as Border;
            var key = cur.Name.Split('_')[1];

            if (curDp == cur)
            {
                //二次点击[播放][注意:重复播放相同歌曲的时候,拉动进度条不会进行变动]
                Media.MusicPlaying(Convert.ToInt32(key));
            }
            curDp = cur;
        }

        public void PlayBoard_MouseEnter(object sender, MouseEventArgs e)
        {
            (sender as Border).BorderBrush = SY_Library.Color.BackColor(128, 255 / 5 * 1);
        }
        public void PlayBoard_MouseLeave(object sender, MouseEventArgs e)
        {
            var cur = sender as Border;
            if (cur.Name != MusicPlayingBoard.curPlayData.Name)
                cur.BorderBrush = SY_Library.Color.BackColor(255, 0);
            else
                cur.BorderBrush = SY_Library.Color.BackColor(103, 58, 183);
        }

        private void PlayBoardHeightSet_MouseEnter(object sender, MouseEventArgs e)
        {
            //注意:此处在播放列表更换后,第一次触发会进行渲染操作,此处会卡顿一下
            MusicPlayingBoard.Show();
        }
        private void PlayBoardHeightSet_MouseLeave(object sender, MouseEventArgs e)
        {
            if (!IsPlayBoardItemMenuDisPlay)
            {
                MusicPlayingBoard.Hidden();
            }
        }

        public void PlayBoardItemDel_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var textblock = sender as TextBlock;
            var dockPanel = textblock.Parent as DockPanel;
            var key = Convert.ToInt32(dockPanel.Name.Split('_')[1]);
            MusicPlayingBoard.DelMusicPlaying(key);
        }




        private void PlayBoardHeightSet_MouseMove(object sender, MouseEventArgs e)
        {
            Console.WriteLine("移动中");
        }

        private void PlayBoardHeightSet_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //LongClicks<StackPanel>.Create(PlayBoardHeightSet, PlayBoardHeightSet_MouseMove, element =>
            //{
            //    element.Background = SY_Library.Color.BackColor(255, 0, 0);
            //});
            //PlayMusicView.Effect
            //DropshadowEff
        }

        private void MusicPlayBoard_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var music = Media.GetCurMusic;
            var displayList = Media.CurDisplayList;
            var curmusic = displayList.FirstOrDefault(u => u.Value.Name == music.Name && u.Value.Singer == music.Singer).Value;
            if (curmusic is not null)
            {
                MusicDisplayList.SelectedIndex = curmusic.Key;
                MusicDisplayList.ScrollIntoView(MusicDisplayList.Items[MusicDisplayList.SelectedIndex]);
            }
            else
            {
                //不在当前显示歌单
            }
        }


    }
}
